﻿/*
Commerce by Onex – eCommerce software platform (www.ecommerce.byonex.com)
Copyright (C) 2008-2010 by Onex Group

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 */
using System;
using System.Data;
using System.Configuration;
using System.Collections.Generic;
using System.Web;
using ShopModel;

namespace ShopModel
{
    /// <summary>
    /// Opisuje kryteria wyszukiwania.
    /// (Describes the search criteria.)
    /// </summary>
    /// <remarks>
    /// Autor: Paweł Janiszewski
    /// Data: 05.2008
    /// Ostania modyfikacja: 19.06.2008 - Paweł Janiszewski
    /// </remarks>
    public class ProductSearchCriteria
    {
        #region Variables

        private string name;
        private int categoryId;
        private decimal priceFrom;
        private decimal priceTo;
        private int producerId;
        private bool promotedOnly;

        private List<ProductProperty> searchCriteria;

        #endregion Variavles

        #region Enums

        public ProductSearchCriteria()
        {
            name = string.Empty;
            categoryId = -1;
            priceFrom = 0;
            priceTo = 0;
            searchCriteria = null;
            producerId = -1;
        }

        #endregion Enums

        #region Fields

        /// <summary>
        /// Nazwa produktu
        /// </summary>
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        /// <summary>
        /// Id kategorii do której należy szukany produkt
        /// </summary>
        public int CategoryId
        {
            get { return categoryId; }
            set { categoryId = value; }
        }

        /// <summary>
        /// Minimalna cena
        /// </summary>
        public decimal PriceFrom
        {
            get { return priceFrom; }
            set { priceFrom = value; }
        }

        /// <summary>
        /// Maksymalna cena
        /// </summary>
        public decimal PriceTo
        {
            get { return priceTo; }
            set { priceTo = value; }
        }

        public int ProducerId
        {
            get { return producerId; }
            set { producerId = value; }
        }

        /// <summary>
        /// Lista dodatkowych właściwości
        /// </summary>
        public List<ProductProperty> SearchCriteria
        {
            get
            {
                return searchCriteria;
            }

            set
            {
                if (searchCriteria == null)
                {
                    searchCriteria = new List<ProductProperty>();
                }
                searchCriteria = value;
            }
        }

        /// <summary>
        /// Ilość dodatkowych właściwości
        /// </summary>
        public int Count
        {
            get
            {
                if (searchCriteria == null)
                {
                    searchCriteria = new List<ProductProperty>();
                }

                return searchCriteria.Count;
            }
        }

        public ProductProperty this[int i]
        {
            get
            {
                return searchCriteria[i];
            }

            set
            {
                searchCriteria[i] = value;
            }
        }


        public bool PromotedOnly
        {
            get { return promotedOnly; }
            set { promotedOnly = value; }
        }

        #endregion Fields
    }

    /// <summary>
    /// Delegat do zdarzenia wyszukiwania produktu
    /// </summary>
    /// <param name="criteria">Kryteria wyszukiwania</param>
    public delegate void ProductSearchEventHandler(ProductSearchCriteria criteria);
}
